home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Include / FWPoint.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  3.5 KB  |  119 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPoint.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWPOINT_H
  13. #define FWPOINT_H
  14.  
  15. #ifndef FWGRDEF_H
  16. #include "FWGrDef.h"
  17. #endif
  18.  
  19. // ----- Fundation Includes -----
  20.  
  21. #ifndef FWSTDDEF_H
  22. #include "FWStdDef.h"
  23. #endif
  24.  
  25. // ----- OpenDoc Includes -----
  26.  
  27. #ifndef _PLFMTYPE_
  28. #include "PlfmType.h"
  29. #endif
  30.  
  31.  
  32. //========================================================================================
  33. //    •• Forward Declarations
  34. //========================================================================================
  35.  
  36. struct FW_CRect;
  37. class FW_CWritableStream;
  38. class FW_CReadableStream;
  39.  
  40. //========================================================================================
  41. //    •• Typedefs
  42. //========================================================================================
  43.  
  44. typedef unsigned short FW_XYSelector;
  45.  
  46. const FW_XYSelector FW_kHorizontal = 0;
  47. const FW_XYSelector FW_kVertical = 1;
  48.  
  49. //========================================================================================
  50. //    •• struct FW_CPoint
  51. //========================================================================================
  52.  
  53. struct FW_CPoint : public XMPPoint
  54. {    
  55. public:
  56.     FW_CPoint() {x = y = 0;}    
  57.     FW_CPoint(XMPCoordinate xx, XMPCoordinate yy)
  58.                     {x=xx; y=yy;}    
  59.     FW_CPoint(const FW_CPoint& point);
  60.     FW_CPoint(const XMPPoint& xmpPoint);
  61.     FW_CPoint(FW_SPlatformPoint plfmPoint);
  62.  
  63.     // ----- Assignement -----    
  64.     FW_CPoint&         operator=(const FW_CPoint& point);
  65.     FW_CPoint&         operator=(const XMPPoint& xmpPoint);
  66.     FW_CPoint&         operator=(FW_SPlatformPoint plfmPoint);
  67.  
  68.     // ----- Conversion -----
  69.     void            AsPlatformPoint(FW_SPlatformPoint& plfmPoint) const;
  70.     operator FW_SPlatformPoint() const;
  71.  
  72.     // ----- Modification -----    
  73.     inline void     Clear()
  74.                         {x=y=0;}
  75.     inline void     Set(XMPCoordinate xx, XMPCoordinate yy)
  76.                         {x=xx; y=yy;}
  77.     void            Offset(XMPCoordinate xx, XMPCoordinate yy);
  78.     void            Map(const FW_CRect& srcRect, const FW_CRect& destRect);
  79.     
  80.     FW_CPoint&        operator+=(const FW_CPoint& point);
  81.     FW_CPoint&        operator-=(const FW_CPoint& point);
  82.     FW_CPoint&        operator+=(const XMPPoint& xmPoint);
  83.     FW_CPoint&        operator-=(const XMPPoint& xmPoint);
  84.     
  85.     FW_CPoint        operator+(const FW_CPoint& point) const;
  86.     FW_CPoint        operator-(const FW_CPoint& point) const;
  87.     FW_CPoint        operator+(const XMPPoint& xmPoint) const;
  88.     FW_CPoint        operator-(const XMPPoint& xmPoint) const;
  89.     FW_CPoint        operator-()  const;
  90.     
  91.     FW_CPoint&        operator+=(FW_SPlatformPoint plfmPoint);
  92.     FW_CPoint&        operator-=(FW_SPlatformPoint plfmPoint);
  93.     FW_CPoint        operator+(FW_SPlatformPoint plfmPoint) const;
  94.     FW_CPoint        operator-(FW_SPlatformPoint plfmPoint) const;
  95.  
  96.     // ----- Accessors -----
  97.     short        IntX() const;
  98.     short        IntY() const;
  99.     
  100.     XMPCoordinate&     operator[](FW_XYSelector selector);
  101.     XMPCoordinate     operator[](FW_XYSelector selector) const;
  102.     
  103.     // ----- Comparison    -----
  104.     FW_Boolean        operator==(const FW_CPoint& point)    const;
  105.     FW_Boolean        operator!=(const FW_CPoint& point)    const;
  106.     FW_Boolean        operator==(const XMPPoint& xmPoint)     const;
  107.     FW_Boolean        operator!=(const XMPPoint& xmPoint)     const;
  108.     
  109.     // ----- Stream -----
  110.     void            Flatten(FW_CWritableStream& stream);
  111.     void            Unflatten(FW_CReadableStream& stream);
  112.     
  113.     // ----- Utilities -----
  114.     static FW_XYSelector FW_CPoint::GetOrthogonal(FW_XYSelector selector)
  115.                                 {return (selector + 1) & 1;}
  116. };
  117.  
  118. #endif
  119.